﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 删除招聘需求相关 : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "SysHrRecruitPool");

            migrationBuilder.DropTable(
                name: "SysHrRecruitRequestBillEntry");

            migrationBuilder.DropTable(
                name: "SysHrRecruitRequestBill");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "SysHrRecruitRequestBill",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    GroupId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    OrgId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    ApprovalTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    Approver = table.Column<string>(type: "nvarchar(64)", maxLength: 64, nullable: true),
                    BillCode = table.Column<string>(type: "nvarchar(128)", maxLength: 128, nullable: false),
                    BillStatus = table.Column<int>(type: "int", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    Remark = table.Column<string>(type: "nvarchar(512)", maxLength: 512, nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    WorkflowStatus = table.Column<int>(type: "int", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysHrRecruitRequestBill", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysHrRecruitRequestBill_FrameworkGroups_GroupId",
                        column: x => x.GroupId,
                        principalTable: "FrameworkGroups",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysHrRecruitRequestBill_SysOrg_OrgId",
                        column: x => x.OrgId,
                        principalTable: "SysOrg",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateTable(
                name: "SysHrRecruitRequestBillEntry",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RecruitRequestBillId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    StaffPoolId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    RecruitCount = table.Column<int>(type: "int", nullable: false),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysHrRecruitRequestBillEntry", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysHrRecruitRequestBillEntry_SysHrRecruitRequestBill_RecruitRequestBillId",
                        column: x => x.RecruitRequestBillId,
                        principalTable: "SysHrRecruitRequestBill",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysHrRecruitRequestBillEntry_SysHrStaffPool_StaffPoolId",
                        column: x => x.StaffPoolId,
                        principalTable: "SysHrStaffPool",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateTable(
                name: "SysHrRecruitPool",
                columns: table => new
                {
                    ID = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
                    RecruitPublishRequestBillId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    RecruitRequestBillEntryId = table.Column<Guid>(type: "uniqueidentifier", nullable: true),
                    BillNo = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CreateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    CreateTime = table.Column<DateTime>(type: "datetime2", nullable: true),
                    HrStatus = table.Column<int>(type: "int", nullable: false),
                    IsPublished = table.Column<bool>(type: "bit", nullable: true),
                    UpdateBy = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: true),
                    UpdateTime = table.Column<DateTime>(type: "datetime2", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SysHrRecruitPool", x => x.ID);
                    table.ForeignKey(
                        name: "FK_SysHrRecruitPool_SysHrRecruitPublishRequestBill_RecruitPublishRequestBillId",
                        column: x => x.RecruitPublishRequestBillId,
                        principalTable: "SysHrRecruitPublishRequestBill",
                        principalColumn: "ID");
                    table.ForeignKey(
                        name: "FK_SysHrRecruitPool_SysHrRecruitRequestBillEntry_RecruitRequestBillEntryId",
                        column: x => x.RecruitRequestBillEntryId,
                        principalTable: "SysHrRecruitRequestBillEntry",
                        principalColumn: "ID");
                });

            migrationBuilder.CreateIndex(
                name: "IX_SysHrRecruitPool_BillNo",
                table: "SysHrRecruitPool",
                column: "BillNo",
                unique: true,
                filter: "BillNo IS NOT NULL");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrRecruitPool_RecruitPublishRequestBillId",
                table: "SysHrRecruitPool",
                column: "RecruitPublishRequestBillId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrRecruitPool_RecruitRequestBillEntryId",
                table: "SysHrRecruitPool",
                column: "RecruitRequestBillEntryId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrRecruitRequestBill_GroupId",
                table: "SysHrRecruitRequestBill",
                column: "GroupId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrRecruitRequestBill_OrgId",
                table: "SysHrRecruitRequestBill",
                column: "OrgId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrRecruitRequestBillEntry_RecruitRequestBillId",
                table: "SysHrRecruitRequestBillEntry",
                column: "RecruitRequestBillId");

            migrationBuilder.CreateIndex(
                name: "IX_SysHrRecruitRequestBillEntry_StaffPoolId",
                table: "SysHrRecruitRequestBillEntry",
                column: "StaffPoolId");
        }
    }
}
